import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

import '../components/PageWrap.dart';

class GridViewLn extends StatefulWidget {
  const GridViewLn({super.key});

  @override
  State<GridViewLn> createState() => _GridViewLnState();
}

class _GridViewLnState extends State<GridViewLn> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          "GridView", // 设置标题文本
          style: TextStyle(
            color: Colors.white, // 设置标题字体颜色
          ),
        ),
        iconTheme: IconThemeData(
          color: Colors.white, // 设置返回图标颜色
        ),
        backgroundColor: Colors.deepPurple, // 设置AppBar背景颜色
      ),
      body: Column(
        children: [
          Expanded(
            child: GridView(
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 3, //横轴三个子widget
                    childAspectRatio: 1.0 //宽高比为1时，子widget
                    ),
                children: <Widget>[
                  Icon(Icons.ac_unit),
                  Icon(Icons.airport_shuttle),
                  Icon(Icons.all_inclusive),
                  Icon(Icons.beach_access),
                  Icon(Icons.cake),
                  Icon(Icons.free_breakfast)
                ]),
          ),
          Expanded(
            child: GridView(
              padding: EdgeInsets.zero,
              gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
                  maxCrossAxisExtent: 120.0, childAspectRatio: 2.0 //宽高比为2
                  ),
              children: <Widget>[
                Icon(Icons.ac_unit),
                Icon(Icons.airport_shuttle),
                Icon(Icons.all_inclusive),
                Icon(Icons.beach_access),
                Icon(Icons.cake),
                Icon(Icons.free_breakfast),
              ],
            ),
          )
        ],
      ),
    );
  }
}
